package  
{
  import flash.display.Bitmap;
  import flash.display.BitmapData;
  import flash.display.Shape;
  import flash.filters.BlurFilter;
  import flash.geom.Matrix;
  import flash.geom.Point;
  import flash.geom.Rectangle;
	/**
   * ...
   * @author Ivan
   */
  public class Platform extends Shape
  {
    [Embed(source = '../assets/platform.png')]
    private var rPlatform:Class;
    
    public static const WIDTH:Number = 150;
    public static const BLUR_LEVELS:int = 6;
    public function Platform() 
    {      
      if (!blur)
      {
        var bmp:Bitmap = new rPlatform();
        var data:BitmapData = bmp.bitmapData;
      
        blur = new Vector.<BitmapData>();
        for (var i:int = 0; i < BLUR_LEVELS; i++)
        {
          var b:BlurFilter = new BlurFilter(0, i, 4);
          var data_clone:BitmapData = new BitmapData(data.width, data.height);
          data_clone.applyFilter(data, new Rectangle(0, 0, WIDTH, 20), new Point(0, 5), b);
          blur.push(data_clone);
        }
      }
    }
    
    public function draw(blur_level:int):void
    {
      var m:Matrix = new Matrix();
      m.translate(0, 0);
      graphics.clear();
      graphics.beginBitmapFill(blur[blur_level], null, false, true);
      graphics.drawRect(0, 5, WIDTH, 20);
      graphics.endFill();
    }
    
    private static var blur:Vector.<BitmapData>;
    
    
    
  }

}